package cn.com.cetccst.compliancecheck.checker;

import android.content.Context;

import cn.com.cetccst.compliancecheck.R;
import cn.com.cetccst.tools.log.CommonLogger;

public class InstallSourceChecker extends Checker {

    private static InstallSourceChecker instance;

    private InstallSourceChecker(Context context) {
        super(CheckerType.InstallSource);
        name = context.getString(R.string.compliance_install_source);
    }

    public static void init(Context context) {
        if (instance == null) {
            instance = new InstallSourceChecker(context);
        }
    }

    public static InstallSourceChecker getInstance() {
        return instance;
    }

    @Override
    public void check(Context context) {
        CommonLogger.info("Start check install source");
        super.check(context);
        if (!isEnable())
            return;
        setResult(CheckResult.Violated);
//TODO 下面是EMM的代码，先不处理了
//        List<InstallSource> blackSourceList = InstallSourceManage.getInstance(context).getBlackSourceList();
//        if (blackSourceList == null || blackSourceList.isEmpty()) {
//            return false;
//        }
//        for (InstallSource blackSource : blackSourceList) {
//            boolean found;
//            if (ProfileHelper.getInstance().isAE()) {
//                found = ProfileHelper.getInstance().findPackageOnDevice(blackSource.getPackageName()) != null;
//            } else {
//                found = PackageUtils.isPackageFoundOnDevice(context, blackSource.getPackageName());
//            }
//            if (found) {
//                violationDetail = blackSource.getMarketName();
//                Logger.log(Log.INFO, "AppsViolationJudger", "found black app " + blackSource.getPackageName());
//                return VIOLATE;
//            }
//        }
//        return NOT_VIOLATE;
    }
}
